home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.4 / CAMD / examples / trans / thinbevel.a < prev    next >
Encoding:
Text File  |  1993-01-01  |  3.3 KB  |  122 lines

  1. ******* ibox.lib/DrawThinBevel **********************************************
  2. *
  3. *   NAME
  4. *       DrawThinBevel -- Draws a thin bevel box, given an IBox and pen colors
  5. *
  6. *   SYNOPSIS
  7. *       DrawThinBevel( rp, box, ulpen, lrpen )
  8. *                  A1  A0   D0     D1
  9. *
  10. *       void __asm DrawThinBevel( register __a1 struct RastPort *,
  11. *                                 register __a0 struct IBox *,
  12. *                                 register __d0 WORD,
  13. *                                 register __d1 WORD );
  14. *
  15. *   FUNCTION
  16. *       This function uses PolyDraw to render a bevel box. The horizontal
  17. *       thickness of the vertical lines is hard-coded at 1, and the vertical
  18. *       thickness of the horizontal lines is hard-coded at 1, for speed.
  19. *
  20. *   INPUTS
  21. *       rp          - RastPort to render to
  22. *       box         - box to render
  23. *       ulpen       - pen number to render upper-left lines in
  24. *       lrpen       - pen number to render lower-right lines in
  25. *
  26. *   EXAMPLE
  27. *
  28. *   NOTES
  29. *
  30. *   BUGS
  31. *
  32. *   SEE ALSO
  33. *       intuition/intuition.h, DrawBevel()
  34. *
  35. *****************************************************************************
  36. *    Written by Talin
  37. *
  38.  
  39.             include        "intuition/intuition.i"
  40.  
  41.             SECTION        text,CODE
  42.  
  43.             xdef        _DrawThinBevel
  44.             xref        _LVOSetAPen,_LVOMove,_LVOPolyDraw,_GfxBase
  45.  
  46. _DrawThinBevel
  47.             movem.l        d2-d7/a2/a6,-(sp)
  48.             move.l        d1,d2                    ; d2 <-- lrpen
  49.             move.l        a1,a2                    ; a2 <-- copy of RP
  50.             move.l        _GfxBase,a6                ; a6 register
  51.  
  52.             moveq        #0,d4                    ; clear upper half of regs
  53.             moveq        #0,d5
  54.             moveq        #0,d6
  55.             moveq        #0,d7
  56.             movem.w        (a0),d4/d5/d6/d7        ; d4 <-- ibox_Left
  57.                                                 ; d5 <-- ibox_Top
  58.                                                 ; d6 <-- ibox_Width
  59.                                                 ; d7 <-- ibox_Height
  60.             add.w        d4,d6                    ; d6 <-- right
  61.             add.w        d5,d7                    ; d7 <-- bottom
  62.             subq.w        #1,d6                    ; d6 <-- left - 1
  63.             subq.w        #1,d7                    ; d7 <-- bottom - 1
  64.  
  65. ;---------- draw upper left part
  66.  
  67.             move.w        d5,-(sp)                ; coords[3] (y) = TOP
  68.             subq.w        #1,d6                    ; subtract 1 from RIGHT
  69.             move.w        d6,-(sp)                ; coords[2] (x) = RIGHT-1
  70.  
  71.             move.w        d5,-(sp)                ; coords[1] (y) = TOP
  72.             move.w        d4,-(sp)                ; coords[0] (x) = LEFT
  73.  
  74. ;            move.l        d0,d0                    ; upper left pen color
  75.             move.l        a2,a1                    ; a1 <-- rp
  76.             jsr            _LVOSetAPen(a6)            ; set it
  77.  
  78.             move.l        d4,d0                    ; d0 <-- LEFT
  79.             move.l        d7,d1                    ; d1 <-- BOTTOM
  80.             subq.w        #1,d1                    ; d1 <-- BOTTOM-1
  81.             move.l        a2,a1                    ; a1 <-- rp
  82.             jsr            _LVOMove(a6)            ; Move to cursor coords
  83.  
  84.             moveq        #2,d0                    ; draw 2 points
  85.             move.l        sp,a0                    ; address of coords
  86.             move.l        a2,a1                    ; a1 <-- rp
  87.             jsr            _LVOPolyDraw(a6)        ; draw the line
  88.  
  89.             lea            8(sp),sp
  90.  
  91. ;---------- draw lower right part
  92.  
  93.             addq.w        #1,d6                    ; d6 <-- RIGHT (fix from before)
  94.  
  95.             move.w        d7,-(sp)                ; coords[3] (y) = BOTTOM
  96.             move.w        d4,-(sp)                ; coords[2] (x) = LEFT + 1
  97.  
  98.             move.w        d7,-(sp)                ; coords[1] (y) = BOTTOM
  99.             move.w        d6,-(sp)                ; coords[0] (x) = RIGHT
  100.  
  101.             move.l        d2,d0                    ; lower right pen color
  102.             move.l        a2,a1                    ; a1 <-- rp
  103.             jsr            _LVOSetAPen(a6)            ; set it
  104.  
  105.             move.l        d6,d0                    ; d0 <-- RIGHT
  106.             move.l        d5,d1                    ; d1 <-- TOP
  107.             addq.w        #1,d1                    ; d1 <-- TOP + 1
  108.             move.l        a2,a1                    ; a1 <-- rp
  109.             jsr            _LVOMove(a6)            ; Move to cursor coords
  110.  
  111.             moveq        #2,d0                    ; draw 2 points
  112.             move.l        sp,a0                    ; address of coords
  113.             move.l        a2,a1                    ; a1 <-- rp
  114.             jsr            _LVOPolyDraw(a6)        ; draw the line
  115.  
  116.             lea            8(sp),sp
  117.  
  118.             movem.l        (sp)+,d2-d7/a2/a6
  119.             rts
  120.  
  121.             end
  122.